Visual Basic 2010 Program: Maze - Create your Maze Without Using Labels

Introduction

In the Visual Studio Help Viewer 1.1 there is an example program called Maze
In order to study this example in tab "Contents" make the following selections:
Helper Viewer Home, Visual Studio 2010, Visual Studio, Visual Studio Languages, Visual Basic and Visual C#, Getting Started Tutorials, Tutorial 2: Create a Maze., Step 2: Create Your Maze using Labels.
In Step 2 you build the maze by using Label controls for each wall. In this example the maze has 40 walls, that means 40 Labels. Those Labels are called: Label1 until Label40. The building of this maze is a very time consuming effort. What is worse: Label controls do not support the array concept.
The program Maze discussed here solves both problems. The whole idea is to use the Toolbox as less as possible. In fact the whole program is based on features that were also available in Visual Basic 5.0.
The only new feature from Visual Basic 2010 that it uses is the BitMap. The Bitmap is used to store and save the maze.

VB Program: Maze - Data Base Description

The program contains two forms: Maze Form1 and Maze Form2.

Besides tools the program uses variables. The most important variables are:

The following pictures show the initial set up and the final setup
  1 1 1 1 1 1 1
  - -   -   - 1
  1   1   1   1
  1 -   -   - 1
  1   1   1   1
  1 -   -   - -
  1 1 1 1 1 1 1
 
    Figure 1
  1 1 1 1 1 1 1
  - - - - 2 2 1
  1 2 1 - 1 2 1
  1 2 1 - 1 2 1
  1 1 1 - 1 1 1
  1 2 2 - - - -
  1 1 1 1 1 1 1

    Figure 2

VB Program Maze: Program Operation

Operation of the program consists of two phases: Maze building and Play.

VB Program Maze: Program description

Program Maze contains the following subroutines:

VB Program Maze: executable and source

In order to get the Visual Basic 2010 executable program use the following zip file:VB2010 Maze exe.zip
The Zip files contains the following file: VB2010 Maze.exe

Listings Maze: Maze.Form1.vb and Maze.Form1.Designer.vb
Listings Maze: Maze.Form2.vb and Maze.Form2.Designer.vb

maze2 Maze example: Size 10


Reflection

The importance of this exercise is to use a small number of tools and a minimum instruction set. The second objective of this exercise is demonstrate the importance of mathematics and to subdivide the problem in subroutines. In fact the mathematics involved to calculate the maze which only has one solution to go from start to finish is what it is all about.
When you study Visual Basic 2010 there is a huge toolbox which in fact has nothing to do with the application.

The reason of this program was a document written by David Platt in the MSDN magazine. For a review of that document go to The silent Majority

For a review about Visual Basic 2010 in General read this: Visual Basic 2010 Evaluation and Criticism


Feedback

No feedback received.


First Release: 25 August 2012

Go back to: Visual Basic 2010 Evaluation and Criticism How to draw a point.
Back to my home page Contents of This Document